/*
 * p3626.cpp
 *
 *  Created on: 2013-7-24
 *      Author: zy
 */
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
const int maxn = 105;
int dp[maxn][205], value[maxn];
vector<pair<int, int> > son[maxn];
int n, m, s;
void init()
{
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i <= n; i++)
		son[i].clear();
}
void dfs(int u, int pa)
{
	for (int i = 0; i <= m; i++)
		dp[u][i] = value[u];
	for (int i = 0; i < son[u].size(); i++)
	{
		int v = son[u][i].first;
		int l = son[u][i].second;
		if (v == pa)
			continue;
		dfs(v, u);
		for (int j = m; j >= 0; j--)
			for (int k = 0; k <= j; k++)
				if (j - k - 2 * l >= 0)
					dp[u][j] = max(dp[u][j], dp[u][j - k - 2 * l] + dp[v][k]);
	}
}
int main()
{
	while (scanf("%d", &n) != EOF)
	{
		init();
		for (int i = 1; i <= n; i++)
			scanf("%d", &value[i]);
		for (int i = 1; i < n; i++)
		{
			int x, y, t;
			scanf("%d%d%d", &x, &y, &t);
			son[x].push_back(make_pair(y, t));
			son[y].push_back(make_pair(x, t));
		}
		scanf("%d%d", &s, &m);
		dfs(s, -1);
		printf("%d\n", dp[s][m]);
	}
	return 0;
}
